<?php

class Application_Model_Dao_ParticularyOrder extends Zend_Db_Table_Abstract
{

	protected $_name = 'particulary_orders';
    protected $_primary = 'id';
    	
	public function init(){
    	
    }
    
 	public function getAll(){
		$result = $this->fetchAll();
		if( !$result )
			throw new Exception("Wystąpił błąd przy pobieraniu danych z bazy. Proszę spróbować jeszcze raz. Jeśli problem będzie się powtarzać, prosimy skontaktować się z administratorem.");	
		return $result;
    } 
	public function getParticularyOrderByID($id){
		$id = (int)$id;
		$row = $this->fetchRow('id = '.$id);
		if (!$row)
			throw new Exception("Szczegół zamówienia o ID $id nie istnieje.");
		return $row->toArray();
	}


	public function saveParticularyOrder($particularyOrder) {
    	$data = array(
			'subject_id' => $particularyOrder->getSubject(),
			'numberWeek' => $particularyOrder->getNumberWeek(),
    		'dimensionSemester' => $particularyOrder->getDimensionSemester(),
    		'hourYear' => $particularyOrder->getHourYear(),
    		'hourSemester' => $particularyOrder->getHourSemester(),
    		'semester_id' => $particularyOrder->getSemester(),
    		'typeCourse_id' => $particularyOrder->getTypeCourse(),
    		'typeCredit_id' => $particularyOrder->getTypeCredit(),
    		'order_id' => $particularyOrder->getOrder(),
    		'userOrder_id' => $particularyOrder->getUserOrder(),
		);
		$this->insert($data);
     return ;
    }

}